<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Services\CategoryService;
use App\Common\Response;
use Illuminate\Support\Facades\Cache;

class CategoryController extends Controller
{

    public function getTree()
    {
        $tree =  Cache::remember('categories_tree', 600, function() {
            $categoryService = new CategoryService;
            return $categoryService->getTree();
        });
        return Response::success($tree);
    }
}
